package jgl.vajra.kingkong.part.home.viewModel;

import java.util.List;
import java.util.Map;

import jgl.vajra.kingkong.bean.CityChoiceBean;
import jgl.vajra.kingkong.bean.HomeCarModelBean;
import jgl.vajra.kingkong.bean.HomeMechanicsBean;
import jgl.vajra.kingkong.bean.MarketPriceBean;
import jgl.vajra.kingkong.bean.OpenCityBean;
import jgl.vajra.kingkong.bean.SpeechInfoBean;
import jgl.vajra.kingkong.part.home.contract.HomePageContract;
import jgl.vajra.kingkong.part.home.model.HomePageModel;
import jgl.vajra.kingkong.widget.mvvm.factory.CreateModel;
import jgl.vajra.kingkong.widget.retrofithelper.rxsubscriber.ProgressObserver;

@CreateModel(HomePageModel.class)
public class HomePageViewModel extends HomePageContract.ViewModel {
    @Override
    public void getSpeechInfoData(Map<String, Object> map) {
        mModel.getSpeechInfoData(map).subscribe(new ProgressObserver<SpeechInfoBean>(false,null) {
            @Override
            public void _onNext(SpeechInfoBean data) {
                mView.returnSpeechInfoBean(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void getCarTypeData(Map<String, Object> map) {
        mModel.getCarTypeData(map).subscribe(new ProgressObserver<List<HomeMechanicsBean>>(false,null) {
            @Override
            public void _onNext(List<HomeMechanicsBean> homeMechanicsBean) {
                mView.returnHomeMechanicsBean(homeMechanicsBean);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void getCarModelData(Map<String, Object> mapCarModel) {
        mModel.getCarModelData(mapCarModel).subscribe(new ProgressObserver<List<HomeCarModelBean>>(false,null) {
            @Override
            public void _onNext(List<HomeCarModelBean> data) {
                mView.returnHomeCarModelBean(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void getMarketPriceData(Map<String, Object> map) {
        mModel.getMarketPriceData(map).subscribe(new ProgressObserver<MarketPriceBean>(false,null) {
            @Override
            public void _onNext(MarketPriceBean data) {
                mView.returnMarketPriceData(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void getAreaInfoData(Map<String, Object> map) {
        mModel.getAreaInfoData(map).subscribe(new ProgressObserver<List<CityChoiceBean>>(false,null) {
            @Override
            public void _onNext(List<CityChoiceBean> cityChoiceBean) {
                mView.returnAreaInfoBean(cityChoiceBean);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void getOpenCityData(Map<String, Object> map) {
        mModel.getOpenCityData(map).subscribe(new ProgressObserver<OpenCityBean>(false,this) {
            @Override
            public void _onNext(OpenCityBean openCityBean) {
                mView.returnOpenCityData(openCityBean);
            }
        });
    }
}
